 <link href="demo.css" rel="stylesheet" type="text/css" />
    <script src="scripts/boot.js" type="text/javascript"></script>
        <script src="scripts/ajaxfileupload.js" type="text/javascript"></script>
 <div id='editForm1'>
    <br/>
      选择Excel文件(格式.xlsx)：<input class="mini-htmlfile" name="uploadfile"  id="file1" style="width:300px;"/>

    <a class="mini-button" onclick="ajaxFileUpload()" enabled="" id='' >&nbsp;&nbsp;导入&nbsp;&nbsp;</a>  
    <a href="/freight.xls">下载Excel模版</a>
    
    <a href="javascript:exportfreight()">导出查询数据</a>
  </div>
<br/>
 <br/>
   <div style="">
        <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
            <table style="width:100%;">
                <tr>
                    <td style="width:100%;">
                  
                     <a class="mini-button"  onclick="saveData()">修改选中记录结算状态</a>    
                    </td>
                    <td style="white-space:nowrap;">
                                                        导入时间:<input id="start" class="mini-datepicker" value="" valueType='string'/>-<input id="end" class="mini-datepicker" value="" valueType='string'/>
                        <input id="key" class="mini-textbox" emptyText="请输入快递单号" style="width:150px;" onenter="onKeyEnter"/>   
                        <a class="mini-button" onclick="search()">查询</a>
                    </td>
                </tr>
            </table>           
        </div>
    </div>
    <div id="datagrid1" class="mini-datagrid" style="height: 500px" 
        url="/warehouse/getfreightData" idField="id" 
        allowResize="true" pageSize="20" 
        allowCellEdit="true" allowCellSelect="true" multiSelect="true" 
        editNextOnEnterKey="true"  editNextRowCell="true"  showFilterRow="true"
        
    >
        <div property="columns">
            <div type="indexcolumn"></div>
            <div type="checkcolumn"></div>
            <div name="LoginName"  field="ExpNo" headerAlign="center" allowSort="true" width="150" >快递单号 
              <input id="expNo" property="filter" class="mini-textbox" style="width:100%;" 
                      onvaluechanged="onFilterChanged" />
               
            </div>
            <div field="ExpCom" width="100" allowSort="true" >快递公司
            <input id="expCom" property="filter" class="mini-textbox" style="width:100%;" 
                      onvaluechanged="onFilterChanged"  />
              
            </div>   
            <div field="Weight" width="100" allowSort="true" >重量
             <input id="Weight" property="filter" class="mini-textbox" style="width:100%;" 
                      onvaluechanged="onFilterChanged"  />
             </div>
            <div field="Cost" width="100" allowSort="true" >成本
             <input id="Cost" property="filter" class="mini-textbox" style="width:100%;" 
                      onvaluechanged="onFilterChanged"  />
             </div>
            <div field="CalcCost" width="100" allowSort="true" >预估运费成本
            <input id="CalcCost" property="filter" class="mini-textbox" style="width:100%;" 
                      onvaluechanged="onFilterChanged"  />
             </div>
            <div field="AvailableCheck" width="100" allowSort="true" >可用性检查 
                 <input id="AvailableCheck" property="filter" class="mini-textbox" style="width:100%;" 
                      onvaluechanged="onFilterChanged"  />
            </div>
            <div field="BillStatus" width="100" allowSort="true" >结算状态
             <input id="BillStatus" property="filter" class="mini-textbox" style="width:100%;" 
                      onvaluechanged="onFilterChanged"  />
            </div>
            
        </div>
    </div>
  
  
<script>

mini.parse();

var grid = mini.get("datagrid1");
grid.load();


function onFilterChanged(e) {
    var expnobox  = mini.get("expNo");
    var expcombox = mini.get("expCom");   
	var  weightbox   = mini.get("Weight");   
    var costbox      = mini.get('Cost');
    var calcCostbox        = mini.get('CalcCost');
    var availableCheckbox  = mini.get('AvailableCheck');
    var billStatusbox      = mini.get('BillStatus');
    
    var expno     = expnobox.getValue().toLowerCase();
    var expcom    = expcombox.getValue().toLowerCase(); 
    var  weight   = weightbox.getValue().toLowerCase();  
    var cost      = costbox.getValue().toLowerCase();
    var calcCost       = calcCostbox.getValue().toLowerCase();
    var availableCheck  =availableCheckbox.getValue().toLowerCase();
    var billStatus      = billStatusbox.getValue().toLowerCase();
    //多条件组合过滤
    grid.filter(function (row) {

       
        var r1 = true;
        if (expnobox) {
            r1 = String(row.ExpNo).toLowerCase().indexOf(expno) != -1;
        }

     
        var r2 = true;
        if (expcombox) {
            r2 = String(row.ExpCom).toLowerCase().indexOf(expcom) != -1;
        }

        var r3 = true;
        if(weightbox){
       		 r3 = String(row.Weight).toLowerCase().indexOf(weight) != -1;
        }

        var r4 = true;
        if(costbox){
       	 r4 = String(row.Cost).toLowerCase().indexOf(cost) != -1;
        }

        var r5 = true;
        if(calcCostbox){
       	 r5 = String(row.CalcCost).toLowerCase().indexOf(calcCost) != -1;
        }

        var r6 = true;
        if(availableCheckbox){
        	r6 = String(row.AvailableCheck).toLowerCase().indexOf(availableCheck) != -1;
        }

        var r7 = true;
        if(billStatusbox){
        	r7 = String(row.BillStatus).toLowerCase().indexOf(billStatus) != -1;
        }
        
        return r1 && r2 &&r3 &&r4&&r5&&r6&&r7 ;
    })

       
    }


function search() {
    var key = mini.get("key").getValue();
    var start = mini.get("start").getValue();
    var end = mini.get("end").getValue();

    grid.load({ key: key,start:start,end:end });
}

function exportfreight(){
	    var key = mini.get("key").getValue();
	    var start = mini.get("start").getValue();
	    var end = mini.get("end").getValue();
	location.href = "/index.php?m=&c=report&a=exportfreight&key="+key+"&start="+start+"&end="+end;
}
function ajaxFileUpload() {
	 mini.mask({
     el: document.body,
     cls: 'mini-mask-loading',
     html: '正在上传...'
 }); 
    
    var inputFile = $("#file1 > input:file")[0];
    jQuery.ajaxFileUpload({
        url: '/Warehouse/importAjax',                 //用于文件上传的服务器端请求地址
        fileElementId: inputFile,               //文件上传域的ID
        //data: { a: 1, b: true },            //附加的额外参数
        dataType: 'json',                   //返回值类型 一般设置为json
        success: function (data, status)    //服务器成功响应处理函数
        {
         
       	 mini.unmask(document.body);
       	 jQuery('#query-bt').show();
       	 
            mini.alert(data.msg);

        },
        error: function (data, status, e)   //服务器响应失败处理函数
        {
       		 mini.unmask(document.body);
             mini.alert(e);
        },
        complete: function () {
            var jq = $("#file1 > input:file");
            jq.before(inputFile);
            jq.remove();
        }
    });
}

function saveData(){
	 
    var data = grid.getSelecteds();
    var ids = '';
  	for(var i=0;i<data.length;i++){
  		ids+=data[i].id+',';
  	 }
	$.ajax({
			url:'/warehouse/updatefreightStatus',
			data:{ids:ids},
			type:'post',
			success:function(data){
				alert(data);
				search();
			}

		})
}
</script>
